package com.LeeCode;

import java.util.Arrays;

/**
 * 求出最多标记下标
 */

public class Code2576 {
    public static void main(String[] args) {
        int[] nums = {3, 5, 2, 4};
        System.out.println(new Code2576().maxNumOfMarkedIndices(nums));
    }

    public int maxNumOfMarkedIndices(int[] nums) {
        Arrays.sort(nums);
        int n = nums.length;
        int left = 0, right = n / 2;
        int count = 0;

        while (left < n / 2 && right < n) {
            if (2 * nums[left] <= nums[right]) {
                count += 2;
                left++;
                right++;
            } else {
                right++;
            }
        }

        return count;
    }
}
